<template>
  <div class="Comment">
    <div class="commentBox">
      <!-- <textarea name="" id="" cols="40" rows="3"></textarea> -->
      <el-input
        type="textarea"
        :autosize="{ minRows: 1, maxRows: 3}"
        placeholder="写评论..."
        v-model="textarea"
        resize="none"
      ></el-input>
      <p :class="{'active':textarea}" @click="goComment">发送</p>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  props: ["commentId",'commentId2'],
  data() {
    return {
      textarea: ""
    };
  },
  watch: {},
  computed: {},
  methods: {
    // 发送评论
    goComment() {
      if (this.textarea) {
        
        if(this.commentId){
          console.log(this.commentId);
          this.$http("/comment", {
          params: {
            t: 1,
            type: 1,
            id: this.commentId,
            content: this.textarea,
            commentId: 0
          }
        }).then(res => {
          console.log(res);
          this.$toast.success('发表失败，请稍后再试');
          this.textarea = "";
        });
        }else{
          console.log(this.commentId2);
          this.$http("/comment", {
          params: {
            t: 1,
            type: 5,
            id: this.commentId2,
            content: this.textarea,
            commentId: 0
          }
        }).then(res => {
          console.log(res);
          this.$toast.success('发表失败，请稍后再试');
          this.textarea = "";
        });
        }
        
      }
    }
  },
  created() {},
  mounted() {}
};
</script>
<style lang="scss" scoped>
@import "~@/assets/css/common.scss";
.Comment {
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  background: #fff;
  border-top: vw(1) solid #ccc;
  padding: vw(8);
  box-sizing: border-box;
  .commentBox {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    p {
      width: vw(50);
      line-height: vw(31);
      text-align: center;
      color: #aaa;
    }
    .active {
      color: #000;
    }
  }
}
</style>

<style lang="scss">
.el-textarea__inner {
  border: none;
}
.el-textarea__inner:focus {
  outline: none;
  border: none;
}
</style>